Mathematical Expressions and Currency Format

Users can add mathematical expressions such as addition, subtraction, multiplication, and division, and currency formatting to the active content template.

When managing prices in an e-commerce system, it's common to store prices as integers (in the smallest currency unit, such as cents for dollars). However, when presenting these prices to users, it's preferable to display them in a more human-readable format, typically with a decimal point separating dollars and cents.

Example: If you have a product in your e-commerce catalog with a price stored as an integer, such as 599, which represents $5.99. Before displaying this price to users, you need to convert it from the integer format to a decimal format.

Show Price in Dollars

To show price in dollars:

  1. On the Active content page, click + Create active content. The Create active content page is displayed.

  2. On the Content tab, under Content Styling, drag the HTML block to the workspace.

Example: If you have a product with the sale price stored in cents (For example, 599 representing $5.99). You want to display this price in dollars.

To display the price in dollars, you can use the following expression:

Copy
{{ {Api.reco.salePriceInCent} /100 }}

This expression divides the sale price in cents by 100 to convert it to dollars. For example, if the sale price is 599 cents, the displayed price will be $5.99.

 

{{ {Model.Offer.value} > 2 ? "Get additional {Model.Offer.value} % off" : ""}}.

For example, {{ 999.56789 | number:0}} will give 1000.

 

{{ {Api.RtPrice.offerPrice} | number:0}}

For example, {{ 999.56789 | number:2}} will give 999.57

 

Calculate and Show Discount

Example: Consider a scenario where you want to display the discount percentage for a product.

To calculate and display the discount percentage, you can use the following expression:

Copy
{{{Api.PriceApi.totalPrice}* (100 -{Api.PriceApi.discount})/100 }}

This expression calculates the discount amount by subtracting the discount from 100, then multiplies it by the total price, and finally divides by 100 to get the percentage. For example, if the total price is $50 and the discount is 20%, the displayed discount will be $10.

Note: These expressions can be directly integrated into your dynamic Active Content templates to accurately represent prices and discounts to your users.